/**
 * 复制功能 
 */
function copyLink() {
	var sUserAgent = navigator.userAgent.toLowerCase();
	var bIsIpad = sUserAgent.match(/ipad/i) == "ipad";
	var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os";
	if(bIsIpad || bIsIphoneOs) {
		//XXX 这里是IOS的代码
		var copyDOM = document.querySelector('#recAddr'); //要复制文字的节点    
		var range = document.createRange();
		// 选中需要复制的节点    
		range.selectNode(copyDOM);
		// 执行选中元素    
		window.getSelection().addRange(range);
		// 执行 copy 操作    
		var successful = document.execCommand('copy');
		try {
			var msg = successful ? 'successful' : 'unsuccessful';
			$.toptip("复制链接成功！", 'success');
		} catch(err) {
			$.toptip("复制链接失败！", 'error');
		}
		// 移除选中的元素    
		window.getSelection().removeAllRanges();
	}else{
		//XXX 这里是android的代码
		var Url2 = document.getElementById("recAddr").innerText;
		var oInput = document.createElement('input');
		oInput.value = Url2;
		document.body.appendChild(oInput);
		oInput.select(); // 选择对象
		document.execCommand("Copy"); // 执行浏览器复制命令
		oInput.className = 'oInput';
		oInput.style.display = 'none';
		$.toptip("复制链接成功！", 'success');
	}
}
/**
 * 获取用户信息
 */
getUser();
var inviteCode;

function getUser() {
	$.ajax({
		type: "POST",
		url: ip + "platform/user/reacquire.m",
		xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
		success: function(data) {
			if(data.statusCode == 0) {
				var code = data.result.inviteCode;
				inviteCode = code;
				url = ip + "appRegistration.html?code=" + inviteCode;
				$("#recAddr").text(url);
				$("#code").qrcode({
					render: "canvas",
					width: 200,
					height: 200,
					text: url
				});
			} else if(data.statusCode == 1000) {
				$.toptip("登录失效！", 'error');
				setTimeout('window.location.href = "signIn.html"', 1000);
			} else {
				$.toptip(data.resultDesc, 'error');
			}
		}
	});
}